﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using SystemCenterSoa.ApiProject.Area.SystemManager;
using SystemCenterSoa.DtoModel.Common;
using SystemCenterSoa.DtoModel.SystemSetup.InstitutionSetting.PeopleManagement;
using SystemCenterSoa.PoModel.SystemSettings.InstituTions;
using SystemCenterSoa.PoModel.SystemSetup.InstitutionSetting.PeopleManagement;
using SystemCenterSoa.Service.SystemSetup.InstitutionSetting.PeopleManagement;

namespace SystemCenterSoa.ApiProject.Area.SystemSetup.InstitutionSetting.PeopleManagement
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [AllowAnonymous]
    public class PeopleController : SystemManagerBaseController
    {
        private PeopleService _peopleService;
        public PeopleController(PeopleService peopleService)
        {
            _peopleService = peopleService;
        }
        [HttpPost]
        public ResultModel<PagerResult<PeopleDto>> SearchPage(SearchModel sm)
        {
            try
            {
                var data = _peopleService.SearchPage(sm);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<PagerResult<PeopleDto>>(ex);
            }
        }
        [HttpPost]
        public ResultModel<bool> PostPeoAdd(PeoplePo m)
        {
            try
            {
                var data = _peopleService.PostPeoAdd(m);
                return MyOk(data);
            }
            catch(Exception ex)
            {
                return MyError<bool>(ex);
            }
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="strarr"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel<bool> PostPenDeletes(string strarr)
        {
            try
            {
                var data=_peopleService.PostPenDeletes(strarr);
                return MyOk(data);
            }
            catch(Exception ex)
            {
                return MyError<bool>(ex);
            }
        }
        [HttpGet]
        public ResultModel<List<DepartmentOfManagementPo>> BinddepartmentSuperiorPos()
        {
            try
            {
                var data = _peopleService.BinddepartmentSuperiorPos();
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<List<DepartmentOfManagementPo>>(ex);
            }
        }

    }
}
